package com.zhiliao.mybatis.mapper;

import com.zhiliao.mybatis.model.TSysRolePermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Description:
 *
 * @author qirong
 * @date 2018-10-26
 */
public interface TSysRolePermissionMapper {

    /**
     * deleteByPrimaryKey
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert
     * @param record
     * @return
     */
    int insert(TSysRolePermission record);

    /**
     * selectByPrimaryKey
     * @param id
     * @return
     */
    TSysRolePermission selectByPrimaryKey(Integer id);

    /**
     * selectAll
     * @return
     */
    List<TSysRolePermission> selectAll();

    /**
     * updateByPrimaryKey
     * @param record
     * @return
     */
    int updateByPrimaryKey(TSysRolePermission record);

    /**
     * selectCountByRoleIdAndPermissionId
     * @param roleId
     * @param permissionId
     * @return
     */
    @Select("select count(0) from t_sys_role_permission where  role_id =#{roleId} and permisson_id =#{permissionId} ")
    int selectCountByRoleIdAndPermissionId(@Param("roleId") Integer roleId,@Param("permissionId") Integer permissionId);

    /**
     * selectByRoleIdAndPermissionId
     * @param roleId
     * @param permissionId
     * @return
     */
    @Deprecated
    @Select("select * from t_sys_role_permission where  role_id =#{roleId} and permisson_id =#{permissionId} ")
    TSysRolePermission selectByRoleIdAndPermissionId(@Param("roleId") Integer roleId,@Param("permissionId") Integer permissionId);

    /**
     * delectByRoleId
     * @param roleId
     * @return
     */
    int delectByRoleId(@Param("roleId") Integer roleId);

    /**
     * delectByPermissionId
     * @param permissionId
     * @return
     */
    int delectByPermissionId(@Param("permissionId") Integer permissionId);
}